/**
 *
 */
package jdk8;

import java.util.Arrays;
import java.util.Collection;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;

import org.junit.Test;

/**
 * @Title:
 * @author zhoujie
 * @date 2016年9月5日 上午10:29:36
 *
 */
public class Test01 {
    /**
     * 过滤指定id的
     */
    @Test
    public void test01() {
        Collection<User> collection = Arrays.asList(new User(1, "01"), new User(2, "02"), new User(3, "03"));
        Collection<Integer> ids = Arrays.asList(3);
        Collection newUsers = collection.stream().filter(u -> ids.contains(ids)).collect(Collectors.toList());
        newUsers.stream().forEachOrdered(u -> System.out.print(u + " "));
    }

    @Test
    public void test02() {
        Collection<User> collection = Arrays.asList(new User(1, "01"), new User(3, "03"));
        Collection ids = collection.stream().map(u -> u.getId()).collect(Collectors.toList());
        // System.out.println(ids);

        Collection newUsers = collection.stream().filter(u -> ids.contains(u.getId())).collect(Collectors.toList());
        newUsers.stream().forEachOrdered(u -> System.out.print(u + " "));
    }

    @Test
    public void test03() {

        Function<Integer, Integer> toInteger = Integer::valueOf;
    }

    @Test
    public void test04() {


        System.out.println();
        Consumer<String> consumer = s -> {
        };
    }

    void println(Consumer<String> consumer) {
        consumer.accept(null);
    }
}
